/*
 * 英才汇硕信息科技有限公司 拥有本软件版权 2023 并保留所有权利。
 * Copyright 2022, YCHS Information&Science Technology Co.,Ltd,
 * All rights reserved.
 */
package com.along.lawyermanage.dongao.controller;

import com.along.lawyermanage.dongao.entity.Lawyer;
import com.along.lawyermanage.dongao.service.LawyerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 律师控制器
 * @author LiulongBing
 * @version 1.0
 * @date 2023/1/3 0003
 */
@Controller
public class LawyerController {

    @Autowired
    LawyerService lawyerService;

    @RequestMapping("/addLawyer")
    public String addLawyer(Lawyer lawyer){
        lawyerService.addLaywer(lawyer);
        //success代表网页 success.html
        return "../static/success";
    }

    @RequestMapping("/show")
    public String showLawyer(Model model){

        List<Lawyer> lawyerList = lawyerService.findLawyer();
        //把lawyerList传递到网页上
        model.addAttribute("lawyerList",lawyerList);
        //displayLawyer代表网页displayLawyer.html
        return "../static/displayLawyer";
    }

    @RequestMapping("/delLawyer")//前端调用的网页
    public String deleteLawyer(int lawyerid){
        lawyerService.removeLawyer(lawyerid);

        return "../static/success";
    }
}
